package com.itheima.day03;
/*
案例3: 求1--100偶数和:
 */


import java.util.Scanner;

public class TestClassCase03 {
    public static void main(String[] args) {
/*
        int sum1=0;
        int sum2=0;
        for (int i = 1; i <= 100 ; i++) {
            if (i % 2==0) {
                sum1 += i;
            }
            else {
                sum2 +=i;
            }

        }
        System.out.println("1--100偶数和:"+sum1);
        System.out.println("1--100奇数和:"+sum2);
     */


        int count = 0;
        int sum=0;

        for (int i = 1; i <= 100; i++) {

            if (i%2==0){
                count++;
                System.out.print("\t"+i);
                if (count % 5==0){
                    System.out.println();
                }

                sum+=i;

            }

            }
        System.out.println("偶数和:"+sum);
        }
    }


